package com.example.ddz;

import java.util.List;

import android.content.Context;

import com.example.ddz.framework.Game;

public class MainMenuScreen {
	 private static final int HELP_BUTTON_INDEX = 2;
	  private static final int HIGHSCORE_BUTTON_INDEX = 4;
	  private static final int MOREGAMES_BUTTON_INDEX = 5;
	  private static final int OPTIONS_BUTTON_INDEX = 3;
	  private static final int START_BUTTON_INDEX = 1;
	  private int currentPressedButton = 0;

	  public MainMenuScreen(Game paramGame)
	  {
	    super(paramGame);
	    this.screenType = 1;
	  }

	  private boolean inBounds(Input.TouchEvent paramTouchEvent, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
	  {
	    if (paramTouchEvent.x > paramInt1)
	    {
	      int i = paramTouchEvent.x;
	      int j = paramInt1 + paramInt3 - 1;
	      if ((i < j) && (paramTouchEvent.y > paramInt2))
	      {
	        int k = paramTouchEvent.y;
	        int m = paramInt2 + paramInt4 - 1;
	        if (k >= m);
	      }
	    }
	    for (int n = 1; ; n = 0)
	      return n;
	  }

	  public void dispose()
	  {
	  }

	  public void pause()
	  {
	    Settings.save(this.game.getFileIO());
	  }

	  public void present(float paramFloat)
	  {
	    Graphics localGraphics = this.game.getGraphics();
	    Pixmap localPixmap1 = Assets.backgroundStart;
	    localGraphics.drawPixmap(localPixmap1, 0, 0);
	    Pixmap localPixmap2 = Assets.dizhu;
	    localGraphics.drawPixmap(localPixmap2, 60, 60);
	    label93: label120: int n;
	    int i1;
	    label195: int i3;
	    int i4;
	    if (this.currentPressedButton == 1)
	    {
	      Pixmap localPixmap3 = Assets.buttonPressed;
	      localGraphics.drawPixmap(localPixmap3, 490, 95);
	      if (this.currentPressedButton != 2)
	        break label319;
	      Pixmap localPixmap4 = Assets.buttonPressed;
	      localGraphics.drawPixmap(localPixmap4, 490, 175);
	      if (this.currentPressedButton != 4)
	        break label341;
	      Pixmap localPixmap5 = Assets.buttonPressed;
	      localGraphics.drawPixmap(localPixmap5, 490, 255);
	      int i = Assets.soundOn.getRawWidth();
	      int j = 744 - i - 15;
	      int k = 334;
	      int m = Assets.soundOff.getRawWidth();
	      n = 744 - m - 15;
	      i1 = 334;
	      if (!Settings.getSoundEnabled())
	        break label363;
	      Pixmap localPixmap6 = Assets.soundOn;
	      localGraphics.drawPixmap(localPixmap6, j, k);
	      int i2 = Assets.moreGames.getRawWidth();
	      i3 = 800 - i2;
	      i4 = 0;
	      if (this.currentPressedButton != 5)
	        break label383;
	      Pixmap localPixmap7 = Assets.moreGamesPressed;
	      localGraphics.drawPixmap(localPixmap7, i3, i4);
	    }
	    while (true)
	    {
	      Pixmap localPixmap8 = Assets.buttonSStart;
	      localGraphics.drawPixmap(localPixmap8, 560, 115);
	      Pixmap localPixmap9 = Assets.buttonSHelp;
	      localGraphics.drawPixmap(localPixmap9, 560, 195);
	      Pixmap localPixmap10 = Assets.buttonSHightscore;
	      localGraphics.drawPixmap(localPixmap10, 560, 275);
	      return;
	      Pixmap localPixmap11 = Assets.button;
	      localGraphics.drawPixmap(localPixmap11, 490, 95);
	      break;
	      label319: Pixmap localPixmap12 = Assets.button;
	      localGraphics.drawPixmap(localPixmap12, 490, 175);
	      break label93;
	      label341: Pixmap localPixmap13 = Assets.button;
	      localGraphics.drawPixmap(localPixmap13, 490, 255);
	      break label120;
	      label363: Pixmap localPixmap14 = Assets.soundOff;
	      localGraphics.drawPixmap(localPixmap14, n, i1);
	      break label195;
	      label383: Pixmap localPixmap15 = Assets.moreGames;
	      localGraphics.drawPixmap(localPixmap15, i3, i4);
	    }
	  }

	  public void resume()
	  {
	  }

	  public void update(float paramFloat)
	  {
	    List localList1 = this.game.getInput().getTouchEvents();
	    List localList2 = this.game.getInput().getKeyEvents();
	    int i = localList1.size();
	    int j = 0;
	    int k = j;
	    int m = i;
	    if (k >= m)
	      return;
	    List localList3 = localList1;
	    int n = j;
	    Input.TouchEvent localTouchEvent1 = (Input.TouchEvent)localList3.get(n);
	    int i1 = Assets.moreGames.getRawWidth();
	    int i2 = Assets.moreGames.getRawHeight();
	    int i3 = 800 - i1;
	    int i4 = 0;
	    int i5 = Assets.soundOn.getRawWidth();
	    int i6 = Assets.soundOn.getRawHeight();
	    int i7 = 744 - i5 - 15;
	    int i8 = 334;
	    if (localTouchEvent1.type == 1)
	    {
	      int i9 = 0;
	      this.currentPressedButton = i9;
	      if (inBounds(localTouchEvent1, 490, 95, 254, 64))
	      {
	        Game localGame1 = this.game;
	        Game localGame2 = this.game;
	        ChooseLevelScreen localChooseLevelScreen = new ChooseLevelScreen(localGame2);
	        localGame1.setScreen(localChooseLevelScreen);
	      }
	      if (inBounds(localTouchEvent1, 490, 175, 254, 64))
	      {
	        Game localGame3 = this.game;
	        Game localGame4 = this.game;
	        HelpScreen localHelpScreen = new HelpScreen(localGame4);
	        localGame3.setScreen(localHelpScreen);
	      }
	      if (inBounds(localTouchEvent1, 490, 255, 254, 64))
	      {
	        Leaderboard localLeaderboard1 = new com/openfeint/api/resource/Leaderboard;
	        Leaderboard localLeaderboard2 = localLeaderboard1;
	        String str = "981806";
	        localLeaderboard2.<init>(str);
	        Dashboard.openLeaderboard(localLeaderboard1.resourceID());
	      }
	      MainMenuScreen localMainMenuScreen1 = this;
	      int i10 = i3;
	      int i11 = i4;
	      int i12 = i1;
	      int i13 = i2;
	      if (localMainMenuScreen1.inBounds(localTouchEvent1, i10, i11, i12, i13))
	      {
	        Context localContext = (Context)this.game;
	        int[] arrayOfInt = MoreGameConstant.game_icon;
	        String[] arrayOfString1 = MoreGameConstant.game_name;
	        String[] arrayOfString2 = MoreGameConstant.game_info;
	        String[] arrayOfString3 = MoreGameConstant.game_package;
	        new FlyfishMoreGames(localContext, arrayOfInt, arrayOfString1, arrayOfString2, arrayOfString3).showMoreGames();
	      }
	    }
	    while (true)
	    {
	      j += 1;
	      break;
	      if ((localTouchEvent1.type != 0) && (localTouchEvent1.type != 2))
	        continue;
	      if (localTouchEvent1.type == 0)
	      {
	        MainMenuScreen localMainMenuScreen2 = this;
	        Input.TouchEvent localTouchEvent2 = localTouchEvent1;
	        if (localMainMenuScreen2.inBounds(localTouchEvent2, i7, i8, i5, i6))
	          Settings.toggleSound();
	      }
	      int i14 = 0;
	      this.currentPressedButton = i14;
	      MainMenuScreen localMainMenuScreen3 = this;
	      Input.TouchEvent localTouchEvent3 = localTouchEvent1;
	      if (localMainMenuScreen3.inBounds(localTouchEvent3, 490, 95, 254, 64))
	      {
	        int i15 = 1;
	        this.currentPressedButton = i15;
	      }
	      MainMenuScreen localMainMenuScreen4 = this;
	      Input.TouchEvent localTouchEvent4 = localTouchEvent1;
	      if (localMainMenuScreen4.inBounds(localTouchEvent4, 490, 175, 254, 64))
	      {
	        int i16 = 2;
	        this.currentPressedButton = i16;
	      }
	      MainMenuScreen localMainMenuScreen5 = this;
	      Input.TouchEvent localTouchEvent5 = localTouchEvent1;
	      if (localMainMenuScreen5.inBounds(localTouchEvent5, 490, 255, 254, 64))
	      {
	        int i17 = 4;
	        this.currentPressedButton = i17;
	      }
	      MainMenuScreen localMainMenuScreen6 = this;
	      Input.TouchEvent localTouchEvent6 = localTouchEvent1;
	      int i18 = i3;
	      int i19 = i4;
	      int i20 = i1;
	      int i21 = i2;
	      if (!localMainMenuScreen6.inBounds(localTouchEvent6, i18, i19, i20, i21))
	        continue;
	      int i22 = 5;
	      this.currentPressedButton = i22;
	    }
	  }
}
